<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\enum;

class ServiceCostEnum
{
    /**
     * @var array 任务redis队列名
     */
    public const CACHE_CONFIG = [
        'media_cost_compare_list' => 'task:media_cost:compare:' . RedisEnum::REDIS_LIST,
        'media_cost_lock' => [
            CommonEnum::OE_MEDIA => 'oe:cost:stat:lock:%d:%s:%d:' . RedisEnum::REDIS_STRING,
            CommonEnum::KS_MEDIA => 'ks:cost:stat:lock:%d:%s:%d:' . RedisEnum::REDIS_STRING,
            CommonEnum::QQ_MEDIA => 'qq:cost:stat:lock:%d:%s:%d:' . RedisEnum::REDIS_STRING,
        ],

        'media_pic_cost_lock' => [
            CommonEnum::OE_MEDIA => 'oe:pic:cost:stat:lock:%d:%s:%d:' . RedisEnum::REDIS_STRING,
            CommonEnum::KS_MEDIA => 'ks:pic:cost:stat:lock:%d:%s:%d:' . RedisEnum::REDIS_STRING,
            CommonEnum::QQ_MEDIA => 'qq:pic:cost:stat:lock:%d:%s:%d:' . RedisEnum::REDIS_STRING,
        ],

        'media_append_cost_lock' => [
            CommonEnum::OE_MEDIA => 'oe:append:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
            CommonEnum::KS_MEDIA => 'ks:append:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
            CommonEnum::QQ_MEDIA => 'qq:append:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
        ],

        'media_pic_append_cost_lock' => [
            CommonEnum::OE_MEDIA => 'oe:pic:append:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
            CommonEnum::KS_MEDIA => 'ks:pic:append:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
            CommonEnum::QQ_MEDIA => 'qq:pic:append:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
        ],

        'media_account_cost_lock' => [
            CommonEnum::OE_MEDIA => 'oe:account:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
            CommonEnum::KS_MEDIA => 'ks:account:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
            CommonEnum::QQ_MEDIA => 'qq:account:cost:stat:lock:%s:' . RedisEnum::REDIS_STRING,
        ],
    ];

    /**
     * @var int 账户类型
     */
    public const TASK_TYPE_ACCOUNT = 1;

    /**
     * @var int 视频类型
     */
    public const TASK_TYPE_VIDEO = 2;

    /**
     * @var int 图片类型
     */
    public const TASK_TYPE_PICTURE = 3;

    /**
     * @var array 比较间隔
     */
    public const COMPARE_GAP = [
        self::TASK_TYPE_ACCOUNT => [2],
        self::TASK_TYPE_VIDEO => [2],
        self::TASK_TYPE_PICTURE => [2],
    ];

    /**
     * @var array 任务redis队列名
     */
    public const TASK_REDIS_KEY = [
        self::TASK_TYPE_ACCOUNT => 'task:cost:account:{media}:{date}:' . RedisEnum::REDIS_LIST,
        self::TASK_TYPE_VIDEO => 'task:cost:video:{media}:{date}:' . RedisEnum::REDIS_LIST,
        self::TASK_TYPE_PICTURE => 'task:cost:pic:{media}:{date}:' . RedisEnum::REDIS_LIST,
    ];

    /**
     * @var array 回溯任务redis队列名
     */
    public const TASK_RECALL_REDIS_KEY = [
        self::TASK_TYPE_ACCOUNT => 'task:recall:account:{media}:{date}:' . RedisEnum::REDIS_LIST,
        self::TASK_TYPE_VIDEO => 'task:recall:video:{media}:{date}:' . RedisEnum::REDIS_LIST,
        self::TASK_TYPE_PICTURE => 'task:recall:pic:{media}:{date}:' . RedisEnum::REDIS_LIST,
    ];

    /**
     * @var string 发送提醒队列名
     */
    public const NOTICE_REDIS_KEY = 'task:notice:' . RedisEnum::REDIS_LIST;

    /**
     * @var int 锁时间
     */
    public const TASK_REDIS_LOCK_TTL = 300;

    /*
     * @var int 待执行状态
     */
    public const TASK_STATUS_WAIT = 0;

    /*
     * @var int 已拉取状态
     */
    public const TASK_STATUS_SUCCESS = 1;

    /*
    * @var int 拉取失败状态
    */
    public const TASK_STATUS_FAIL = 2;

    /**
     * @var array 状态数组
     */
    public const TASK_STATUS_ARR = [
        self::TASK_STATUS_WAIT => '待执行',
        self::TASK_STATUS_SUCCESS => '成功',
        self::TASK_STATUS_FAIL => '失败',
    ];

    /**
     * @var int token获取失败报错
     */
    public const ERROR_TOKEN_CODE = 4001;

    /**
     * @var int 权限报错
     */
    public const ERROR_AUTH_CODE = 4002;

    /**
     * @var int 接口报错
     */
    public const ERROR_API_CODE = 4003;

    /**
     * @var int 系统错误
     */
    public const ERROR_SYSTEM_CODE = 4004;

    /**
     * @var array 媒体授权权限错误码
     */
    public const MEDIA_ERROR_AUTH_CODE = [
        CommonEnum::OE_MEDIA => [
            40002,
        ],
        CommonEnum::KS_MEDIA => [
            400004, 400002,
        ],
        CommonEnum::QQ_MEDIA => [
            11014, 32208, 32238, 32230,
        ],
    ];

    /**
     * @var int 提醒成功状态
     */
    public const NOTICE_STATUS_SUCCESS = 1;
}
